<html>

	<head>
		<meta charset="UTF-8">
		<title>合同日计划</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<link rel="stylesheet" href="../../layui/css/layui.css" />
		<link rel="stylesheet" href="../../css/bass.css" />
		<link rel="stylesheet" href="../../css/air/arrPay.css" />
		<style>
			.layui-input-block{
				margin-left: 60px !important;
				margin-top: 1px;
			}
			.left{
				margin-left: 20px;
			}
		</style>
	</head>

	<body>
		<div class="body contractDay">
			<header class="layui-nav" id="headerTop"></header>
			<div class="left_muen" id="left_menu"></div>
			<div class="content_body contractDay">
				<p class="content_title">气量管理&nbsp;&nbsp;>&nbsp;&nbsp;合同日计划</p>

				<div class="content_seach">
					<div class="layui-form">
						<div class="layui-inline">
							<label class="layui-form-label">日期</label>

							<div class="layui-input-inline">
								<input type="text" class="layui-input" name="startTime" id="test31" placeholder="请输入起始日期">
							</div>
							<div class="layui-input-inline">
								<input type="text" class="layui-input" name="endTime" id="test32" placeholder="请输入结束日期">
							</div>
							<div class="layui-inline left">
								<label class="layui-form-label">上报</label>
								<div class="layui-input-block">
									<select name="status" lay-verify="required" lay-search="">
										<option value="">请选择是否上报</option>
										<option value="1">是</option>
										<option value="0">否</option>
									</select>
								</div>
							</div>
						</div>
						<div class="layui-btn layui-btn-warm search layui-btn-sm" id="search" lay-submit="" lay-filter="search">
							<i class="layui-icon">&#xe615;</i>查询
						</div>
					</div>
				</div>
				<div class="content_table">
					<script type="text/html" id="toolbarDemo">
  						<div class="layui-btn-container">
    						<button class="layui-btn layui-btn-sm" lay-event="getCheckData"><i class="layui-icon">&#xe645;</i>催上报</button>
  						</div>
					</script>
					<div class="tabTable">
						<table id="demo" lay-filter="table" lay-data="{id:'idTest'}"></table>
						<div class="layui-table-page fr">
							<div id="layui-table-page1"></div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<script type="text/html" id="maTypeTemplet">
			{{#if (d.status == 0) { }}
	 		否
			{{# }else if(d.status == 1){ }}
	 		是
			{{# } }}
		</script>
		<script type="text/html" id="statusTemplet">
			<!--{{#if (d.status == 1) { }}-->
				<input type="checkbox" name="layTableCheckbox" lay-skin="primary" {{d.status == 1 ?'checked':''}}>
			<!--{{# } }}-->
		</script>
		<script src="../../js/common/jquery-1.11.3.min.js"></script>
		<script src="../../layui/layui.js"></script>
		<script src="../../js/common/navList.js"></script>
		<script src="../../js/common/ajax.js"></script>
		<script>
			layui.use(['table', 'form','laydate'], function() {
				var form = layui.form;
				var table = layui.table;
				var laydate = layui.laydate;
				laydate.render({
					elem: '#test31',
					theme: 'grid',
				});
				laydate.render({
					elem: '#test32',
					theme: 'grid',
				});
				//初始化第一个实例
				ajaxTable({
					idNode: '#demo',
					url: 'contractdayplan/getList',
					dataCols: [
						{fixed: true,checkbox: true,status:'status',status:'status',templet:'#statusTemplet'},
						{field: 'organization',title: '下游组织',align: 'center',},
						{field: 'contractName',title: '合同',align: 'center'},
						{field: 'siteName',title: '站点',align: 'center'},
						{field: 'unit',title: '单位',align: 'center'},
						{field: 'forecastPlanVal',title: '预测日指定计划',align: 'center'},
						{field: 'planVal',title: '日指定计划',align: 'center'},
						{field: 'status',title: '是否已上报',align: 'center',templet:'#maTypeTemplet'},
						{field: 'planDesc',title: '备注1',align: 'center'},
					],
					successFull: function(res, curr, count, table) {
//						console.log($(".layui-table-fixed .laytable-cell-checkbox").eq(2).find(".layui-unselect.layui-form-checkbox").css("display","none"))
						
						$.each(res.list, function(i,item) {
							if(item.status == 1){
//								$(".layui-table-fixed .laytable-cell-checkbox").eq(i).find(".layui-unselect.layui-form-checkbox").remove();
//								$(".layui-table-fixed .laytable-cell-checkbox").eq(i).find("input").remove();
								$(".layui-table-fixed tr").eq(i+1).find(".laytable-cell-checkbox input").remove();
								$(".layui-table-fixed tr").eq(i+1).find(".laytable-cell-checkbox .layui-unselect.layui-form-checkbox").remove();
							}
						});
//						$(".laytable-cell-checkbox").eq(2).css('display','none');
//						$.each($(".layui-table-main input"),function(i,item){
//							var $_this = $(this);
//							$.each($_this.parent().parent().siblings(),function(j,sibling){
//								if($(sibling).attr("data-field")== 'status'){
//									if($(this).attr("data-content") == 1){
//										console.log($_this)
////										$_this.siblings().css({display:"none"})
//										$_this.siblings().remove()
//										$_this.siblings().find("i").remove()
//										$_this.remove();
//										$(".layui-table-fixed .layui-table-body tr").eq(i).find(".laytable-cell-checkbox").css({display:"none"})
//									}
//								}
//							})
//						});
						table.on('toolbar(table)', function(obj) {
							var checkStatus = table.checkStatus(obj.config.id);
							if(obj.event == 'getCheckData'){
								var data = checkStatus.data;
//									layer.alert(JSON.stringify(data));
							}
						});
					}
				});
				//        条件查询
				form.on('submit(search)', function(data) {
					//            data.field.devicename = !data.field.devicename?"":data.field.devicename;
					ajaxTable({
						idNode: '#demo',
						url: 'contractdayplan/getList',
						urlParme: '&startTime=' + data.field.startTime + '&endTime=' + data.field.endTime + '&status=' + data.field.status,
						dataCols: [
							{fixed: true,checkbox: true,status:'status',templet:'#statusTemplet'},
							{field: 'organization',title: '下游组织',align: 'center',},
							{field: 'contractName',title: '合同',align: 'center'},
							{field: 'siteName',title: '站点',align: 'center'},
							{field: 'unit',title: '单位',align: 'center'},
							{field: 'forecastPlanVal',title: '预测日指定计划',align: 'center'},
							{field: 'planVal',title: '日指定计划',align: 'center'},
							{field: 'status',title: '是否已上报',align: 'center',templet:'#maTypeTemplet'},
							{field: 'planDesc',title: '备注1',align: 'center'},
							//                    {field: 'right', title: '操作', width: 170, toolbar: "#barContractUpdate"}
						],
						successFull: function(res, curr, count,table) {
							$.each($(".layui-table-main input"),function(i,item){
								var $_this = $(this);
								$.each($_this.parent().parent().siblings(),function(j,sibling){
									if($(sibling).attr("data-field")== 'status'){
										if($(this).attr("data-content") == 1){
											console.log($_this)
											$_this.siblings().css({display:"none"})
											$_this.siblings().find("i").remove()
											$_this.remove();
											$(".layui-table-fixed .layui-table-body tr").eq(i).find(".laytable-cell-checkbox").css({display:"none"})
										}
									}
								})
							});
							table.on('toolbar(table)', function(obj) {
								var checkStatus = table.checkStatus(obj.config.id);
								if(obj.event == 'getCheckData'){
									var data = checkStatus.data;
									layer.alert(JSON.stringify(data));
								}
							});
						}
					});
				});
			});
		</script>
	</body>

</html>